#include "main.h"
#include "Interrupt.h"
#include "McuInit.h"
#include "app.h"

u8	Time2msFlag = 0;
u8	Time2msCnt = 0;

void main(void)
{
	WDT_Reset_Init();
	Gpio_Init();
	Uart_Open(UART1_Timer3,4800);	
	ADC_Init();
	Timer0_Init(400);	// 400us
	ENABLE_GLOBAL_INTERRUPT;      //enable interrupts;
	for(;;)
	{
		Uart_Rxd_Handle();
		//Uart_Txd_Handle();
		if(Time2msFlag)
		{
			Time2msFlag = 0;
			set_WDCON_WDCLR;	//Clear WDT count for avoid reset
			IR_Handle();
			IROverTimeHandle();
			SegScan();
			Uart_Error_Handle();
			Time2msCnt ++;
			if(Time2msCnt >= 8)
			{
				Time2msCnt = 0;
				Ad_Service();
			}
		}
	}
}
